<?php

namespace App\Http\Resources\Api\Admin;

use App\Models\Enum\Admin\AdminUserEnum;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Http\Business\PowerBusiness;

class AdminUsersResource extends JsonResource
{

    public function toArray($request)
    {
        return [
            'user_id'=>$this->user_id,
            'name' => $this->name,
            'phone' => $this->phone,
//            'statusName' => AdminUserEnum::getStatusName($this->status),
            'status' => $this->status,
            'avatar' => $this->avatar,
            'wechat' => $this->wechat,
            'qq' => $this->qq,
            'email' => $this->email,
            'logined_at' => $this->logined_at,
            'roles' => AdminUsersRoleResource::collection($this->roles),
            'ips' => AdminUsersIpResource::collection($this->ips),
            'isSupper' => PowerBusiness::isSuperAdmin($this->phone) ? 1 : 0,
            'created_at'=>(string)$this->created_at,
            'updated_at'=>(string)$this->updated_at
        ];
    }
}
